//
//  GPSExerciseTypeTableViewCell.swift
//  DaFit
//
//  Created by Paul on 2022/10/27.
//  Copyright © 2022 sylar. All rights reserved.
//

import UIKit
import MYModule

open class TrainingTypeTableViewCell: UITableViewCell {
    
    public let exerciseTypeImage = UIImageView()
    
    public let bgView = UIView()
    
    public let titleLabel = UILabel()
    
    public let accessoryIcon = UIImageView()

    public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        makeUI()
    }
    
    public required init?(coder: NSCoder) {
        super.init(coder: coder)
        
        makeUI()
    }
    

    open func makeUI() {
        
        contentView.addSubview(bgView)
        bgView.addSubview(exerciseTypeImage)
        
        bgView.addSubview(titleLabel)
        bgView.addSubview(accessoryIcon)
        
        titleLabel.font = Fonts.systemFont(ofSize: 16)
        titleLabel.textColor = UIColor.assist_222222
        titleLabel.text = ""
        accessoryIcon.image = UIImage(named: "ic_continue")
        
        bgView.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(40)
            make.right.equalToSuperview().offset(-20)
            make.top.equalToSuperview().offset(15)
            make.bottom.equalToSuperview().offset(-15)
        }
        bgView.backgroundColor = .white
        setShadow(view: bgView,sColor: .black,cornerRadius: 10)
        
        exerciseTypeImage.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(15)
            make.centerY.equalToSuperview()
            make.bottom.lessThanOrEqualToSuperview()
           
        }
        
        accessoryIcon.snp.makeConstraints { make in
            make.right.equalTo(-20)
            make.height.width.equalTo(22)
            make.centerY.equalToSuperview()
        }
        
        titleLabel.snp.makeConstraints { make in
            make.left.equalTo(exerciseTypeImage.snp.right).offset(10)
            make.right.lessThanOrEqualTo(accessoryIcon.snp.left).offset(-10)
            make.centerY.equalToSuperview()
        }
        
    }
    
    open func setTitle(title: String?){
        self.titleLabel.text = title
    }
    
    open func setImage(image: UIImage?){
        self.exerciseTypeImage.image = image
    }
}
